FROM rick.jxnews.com.cn/rick/node:21-alpine3.18

# RUN data="" \
# && for s in $(wget -qO- http://mirrors.aliyun.com/alpine/MIRRORS.txt); do t=$(time -f "%E" wget -T1 -q $s/MIRRORS.txt -O /dev/null 2>&1) && echo "$s was $t" && data="$data$t $s\n"; done \
# && echo -e $data | sort \
# && newrepo=`echo -e $data | sort | head -2 | tail -1 | awk '{print $3}'` \
# && repo=${newrepo//\//\\/} \
# && sed -i 's/http:\/\/dl-cdn.alpinelinux.org\/alpine\//'"$repo"'/g' /etc/apk/repositories

# 设置阿里云的APK加速源
RUN echo "https://mirrors.aliyun.com/alpine/latest-stable/main" > /etc/apk/repositories && \
    echo "https://mirrors.aliyun.com/alpine/latest-stable/community" >> /etc/apk/repositories

RUN apk update
RUN apk add imagemagick 
RUN apk add ffmpeg 
# RUN apk add phantomjs 


# ENV PHANTOMJS_ARCHIVE="phantomjs.tar.gz"
# RUN apk add wget
# RUN wget -Lk -o $PHANTOMJS_ARCHIVE https://github.com/fgrehm/docker-phantomjs2/releases/download/v2.0.0-20150722/dockerized-phantomjs.tar.gz \
# && tar -xf $PHANTOMJS_ARCHIVE -C /tmp/ \
# && cp -R /tmp/etc/fonts /etc/ \
# && cp -R /tmp/lib/* /lib/ \
# && cp -R /tmp/lib64 / \
# && cp -R /tmp/usr/lib/* /usr/lib/ \
# && cp -R /tmp/usr/lib/x86_64-linux-gnu /usr/ \
# && cp -R /tmp/usr/share/* /usr/share/ \
# && cp /tmp/usr/local/bin/phantomjs /usr/bin/ \
# && rm -fr $PHANTOMJS_ARCHIVE /tmp/*


COPY ./phantomjs-2.1.1-linux-x86_64.tar.bz2 /usr/local/src/phantomjs-2.1.1-linux-x86_64.tar.bz2
RUN tar -jxvf /usr/local/src/phantomjs-2.1.1-linux-x86_64.tar.bz2 -C /usr/local
RUN ln -s /usr/local/phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/local/bin

RUN npm config set registry https://registry.npmmirror.com
RUN npm i -g pm2

EXPOSE 3000

CMD [ "pm2-runtime", "start", "pm2.json" ]